﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using Ccit.OA.MsNotify;

namespace Ccit.OA.Notify
{
    public partial class notify_reply_list : Ccit.Utils.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["Query"] = "";
                _hidsRecId.Value = (null != Request.QueryString["NotifyId"]) ? Request.QueryString["NotifyId"].ToString() : "";
            }
            if (_hidsRecId.Value!="")
                    DataBindn();
        }
        /// <summary>
        /// grid 绑定
        /// </summary>
        private void DataBindn()
        {
            NotifyBLL Bll = new NotifyBLL();
            List<MsNotifyMessage> lstMes = Bll.GetReplyViewMes(_hidsRecId.Value, ViewState["Query"].ToString());
            dgMain.DataSource = lstMes;
            dgMain.DataBind();
        }

        protected void dgMain_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
        {
            if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.Data) return;            
            string state = dgMain.GetRowValues(e.VisibleIndex, "state").ToString();
            string content = dgMain.GetRowValues(e.VisibleIndex, "content").ToString();
            string receipt = dgMain.GetRowValues(e.VisibleIndex, "receipt").ToString();
            DevExpress.Web.ASPxClasses.Internal.InternalWebControl ochk = (DevExpress.Web.ASPxClasses.Internal.InternalWebControl)e.Row.Cells[0].Controls[0];
            if (state == "0")
            {
                if (receipt == "0")
                {
                    e.Row.Cells[3].Text = "已阅";
                }
                else
                {
                    if (content != "")
                    {
                        e.Row.Cells[3].Text = "已阅已回";
                    }
                    else
                    { e.Row.Cells[3].Text = "已阅未回"; }
                }
                ochk.Enabled = false;
            }
            else
            {
                e.Row.Cells[3].Text = "未阅";
            }
        }

        protected void lnbQuery_Click1(object sender, EventArgs e)
        {
            ViewState["Query"] = "";
            if(ddlPubFlag.SelectedValue!="")
            {
                ViewState["Query"] = ddlPubFlag.SelectedValue;
                DataBindn();
            }
            DevExpress.Web.Data.WebDataSelection oSelect = dgMain.Selection;
            oSelect.UnselectAll();
        } 
    }
}
